package com.zoe.onelink.logging.trace.sql.p6spy;

import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
import com.zoe.onelink.util.StrUtil;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-03-08
 */
public class OnelinkSlf4jFormatter implements MessageFormattingStrategy {
    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
        return StrUtil.isNotBlank(sql) ? " 耗时 ：" + elapsed + " ms " + now +
                "\n 执行SQL：" + sql.replaceAll("[\\s]+", " ") + "\n" : "";
    }
}
